package com.trt.workflow;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 谭仁涛
 * @description 流程网关-并行,排他,包含
 * @date 2022/2/20 13:42
 */
@SpringBootTest
public class Part7_Gateway {

    @Autowired
    private RuntimeService runtimeService;

    @Autowired
    private TaskService taskService;

    @Test
    public void initProcessInstance() {
        //ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess_parallel");
        // ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess_Exclusive");
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess_Inclusive");
        System.out.println("流程定义ID："+processInstance.getProcessDefinitionId());
    }

    @Test
    public void completeTask() {
        // taskService.complete("0598814d-9212-11ec-a3bc-00ff6fa8c6c1");
        // System.out.println("完成任务");

        // Map<String, Object> variables = new HashMap<String, Object>();
        // variables.put("day", "100");
        // taskService.complete("d8a31408-9214-11ec-823c-00ff6fa8c6c1", variables);
        // System.out.println("完成任务");

        Map<String, Object> variables = new HashMap<String, Object>();
        // 沙僧id b0af2a99-9219-11ec-8afe-00ff6fa8c6c1
        // 悟空id b0af2a9b-9219-11ec-8afe-00ff6fa8c6c1
        // 流程实例ProcessInstanceId : 5a2563a6-9219-11ec-8e1d-00ff6fa8c6c1
        variables.put("day", "1");
        //taskService.complete("5a28bf0a-9219-11ec-8e1d-00ff6fa8c6c1", variables);
        taskService.complete("b0af2a99-9219-11ec-8afe-00ff6fa8c6c1");
        taskService.complete("b0af2a9b-9219-11ec-8afe-00ff6fa8c6c1");
        System.out.println("完成任务");

    }

}
